<?php if(!defined('A')) exit;?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>网站内容管理系统</title>
<?php
loadcss(array('reset','shell'));
loadcss(array('colorbox'),P_CSS);
loadjs(array('jquery','jquery.colorbox'),P_JS);
loadjs(array('tab','util','table','ovalidator'));
?>
<script type="text/javascript">
$(document).ready(function(e) {
var smallNowTab;
var pt = new Tabs();
pt.classpre="smalltab_";
pt.container = "smalltab_container";
pt.createTab("t1","添加分类","",true,"n");
pt.init = function(){
	smallNowTab = pt.nowTab;
};
pt.onclick = function(){
	smallNowTab = pt.nowTab;
};		
pt.initTab();
pt.clickNowTab();    
});

$(document).ready(function(){ 
	$(".example1").colorbox({width:"400px", height:"400px", iframe:true, opacity:0.3});
});

function abc(f){
		$('#thumburl').val(f);
}

$(document).ready(function(){
	oValidator.add([
		{id:'mid',name:'moduleid',error:'不能为空',empty:false},
		{id:'parent_id',name:'上级分类',error:'不能为空',empty:false},
		{id:'name',name:'名称',error:'不能为空',empty:false},
		{id:'mysort',name:'排序',error:'不能为空',empty:false}
	]); 	
	$('#myform').submit(function(){
		if(!oValidator.pass()){
			alert(oValidator.error_str('\n'));
			return false;
		}
	});
});
</script>
<style>
body{margin:10px;}
</style>
</head>
<body>
<table class="settop">
<tr>
<td class="settop_left">
&nbsp;&nbsp;
</td>
<td>
<div id="smalltab_container"></div>
</td>
</tr>
</table>
<div class="smalltab_line"></div>
<div id="t1">
<br />
<br />
    <form action="<?php echo url('category','add_');?>" method="post" id="myform">
    <table width="90%" class="mytable">
    	<tr>
    	  <td align="right"><span class="red">moduleid:</span></td>
    	  <td align="left"><?php echo $mid;?><input name="mid" id="mid" type="hidden" value="<?php echo $mid;?>" /></td>
  	  </tr>
    	<tr>
    		<td align="right"><span class="red">上级分类：</span></td>
    		<td align="left">
    		<select name="parent_id" id="parent_id">
    		    <option value="0">顶级分类</option>
    		    <?php foreach ($category_arr as $key => $value) { ?>
    		    <option <?php if($selected_c==$value['id']) echo 'selected="selected"';?> value="<?php echo $value['id'] ?>" <?php if($value['type']==0) echo 'disabled="disabled"';?>><?php echo str_repeat('&nbsp;',substr_count($value['path'], ',')*4)?>┖─&nbsp;<?php echo $value['name'] ?><?php if($value['type']==1){echo '√';}else{echo '×';}?></option>
    		    <?php } ?>
    		</select>
    		    
    		</td>
    	</tr>
    	<tr>
            <td align="right"><span class="red">名称：</span></td>
            <td align="left"><input type="text" name="name" class="input" id="name" /><span class="green">(最长50个字符)</span></td>
        </tr>
        <tr>
            <td align="right">简介：</td>
            <td align="left"><textarea name="description" id="description" rows="4" cols="40"></textarea><span class="green">(最长300个字符)</span></td>
        </tr>
        <tr>
            <td align="right"><span class="red">类型：</span></td>
            <td align="left"><?php echo form_radio('type',array(1=>'有下级分类',0=>'无下级分类'),1);?></td>
        </tr>
        <tr>
            <td align="right">排序：</td>
            <td align="left"><input type="text" name="mysort" class="input" id="mysort" value="<?php echo $s;?>" /><span class="green">(正整数，越小越靠前)</span></td>
        </tr>
        <tr style="display:none;">
            <td align="right">目录名称：</td>
            <td align="left"><input type="text" name="dir" class="input" id="dir" value="" /><span class="green">(最长100个字符)</span></td>
        </tr>
        <tr>
            <td align="right">缩略图链接：</td>
            <td align="left"><input type="text" name="thumburl" class="input" id="thumburl" value="" /> [<a class="example1" href="<?php echo url('upload','add','callback=abc');?>">上传</a>]</td>
        </tr>
        <tr>
            <td align="right">链接地址：</td>
            <td align="left"><input type="text" name="linkurl" class="input" id="linkurl" value="" /><span class="green">(最长255个字符)</span></td>
        </tr>
        <tr>
            <td align="right">seo_title：</td>
            <td align="left"><textarea name="seo_title" id="seo_title" rows="4" cols="40"></textarea><span class="green">(最长255个字符)</span></td>
        </tr>
        <tr>
            <td align="right">seo_keywords：</td>
            <td align="left"><textarea name="seo_keywords" id="seo_keywords" rows="4" cols="40"></textarea><span class="green">(最长255个字符)</span></td>
        </tr>
        <tr>
            <td align="right">seo_description：</td>
            <td align="left"><textarea name="seo_description" id="seo_description" rows="4" cols="40"></textarea><span class="green">(最长255个字符)</span></td>
        </tr>
        <tr>
          <td align="right">自定义封面模板：</td>
          <td align="left">
            <select name="tempindex" id="tempindex">
            <?php echo $category_service->my_template(1,'');?>
            </select>
          </td>
        </tr>
        <tr>
          <td align="right">自定义列表模板：</td>
          <td align="left">
            <select name="templist" id="templist">
            <?php echo $category_service->my_template(2,'');?>
            </select>
          </td>
        </tr>
        <tr>
          <td align="right">自定义内容模板：</td>
          <td align="left">
            <select name="tempshow" id="tempshow">
            <?php echo $category_service->my_template(3,'');?>
            </select>
          </td>
        </tr>
        <tr style="display:none;">
          <td align="right">自定义列表地址规则：</td>
          <td align="left"><input type="text" name="rulelist" class="input" id="rulelist" value="" /></td>
        </tr>
        <tr style="display:none;">
          <td align="right">自定义内容地址规则：</td>
          <td align="left"><input type="text" name="ruleshow" class="input" id="ruleshow" value="" /></td>
        </tr>
        <tr>
            <td colspan="2" align="center"><input type="submit" value="提交" class="color_btn color_btn_green" /></td>
        </tr>
    </table>
    </form>
</div>
</body>
</html>